const express = require('express');
const { nextTick } = require('process');
const fs = require('fs');//引入文件读写模块

const app = express();

app.get('/index',(req,res,next)=>{
    // throw new Error('程序发生未知错误');
    fs.readFile('./js/02.js','utf8',(err,result)=>{
        if(err != null){
            next(err);
        }else{
            res.send(result)
        }
    })
})
//错误处理中间件
app.use((err,req,res,next)=>{
    res.status(500).send(err.message)
})


app.listen(3000);
console.log('启动成功');